package com.itheima.common;

public class BaseContext {

    private static ThreadLocal<Long> threadLocal = new ThreadLocal<>();

    // 设置当前用户 ID
    public static void setCurrent(Long id) {
        threadLocal.set(id);
    }

    // 获取当前用户 ID
    public static Long getCurrent() {
        return threadLocal.get();
    }

    // 清除当前线程的用户 ID，防止内存泄漏
    public static void remove() {
        threadLocal.remove();
    }

    public static Long getCurrentId(){
        return threadLocal.get();
    }

}